package com.hkfg.dao;

import com.hkfg.domain.Moment;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface MomentDao {
    @Select("select * from moment where receiver_id = #{receiver_id};")
    List<Moment> selectMomentById(int receiverId);

    @Insert("insert into moment(id, content, createtime, updatetime, sender_id, receiver_id) values (null, #{content}, NOW(), NOW (), #{sender_id}, #{receiver_id});")
    int buildMoment(@Param("content")String content, @Param("sender_id")int senderId, @Param("receiver_id") int receiverId);

    @Select("select * from moment where id = #{id};")
    Moment getMomentById(int id);

    @Delete("delete from moment where id = #{id}")
    int deleteMomentById(int id);

    @Update("update moment set content = #{content} where id = #{id}")
    int modifyMoment(@Param("id") int id, @Param("content") String content);
}